import { defineStore } from "pinia";
import { GRID, F } from "@/utils/global";

export const useOverStore = defineStore('over', {
  state: () => ({
    start: 23 * GRID,
    end: 12 * GRID,
    dur: 72 * F,
    y: 23 * GRID,
    visible: false,
  }),
  actions: {
    playOver(ft) {
      if (this.visible) {
        if (this.y <= this.end) {
          this.visible = false
          this.y = this.start
        } else {
          const step = (this.end - this.start) / this.dur * ft
          this.y += step
        }
      }
    }
  }
})